﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Common;

namespace QuotationSoftware
{
    public partial class MechanicismFrm : Form
    {
        private mForm parentForm;
        private List<Business.CodeDetail> listChecked;

        public MechanicismFrm(List<Business.CodeDetail> list, mForm _parentForm)
        {
            InitializeComponent();

            Init(list, _parentForm);
        }

        private void Init(List<Business.CodeDetail> _list, mForm _parentForm)
        {
            this.parentForm = _parentForm;

            clb_Mech.DataSource = _list;
        }

        private void bt_OK_Click(object sender, EventArgs e)
        {
            if ((clb_Mech.CheckedItems.Count) != 0)
            {
                DialogResult dr = MessageBox.Show(Common.MESSAGE_STRING.CONFIRM_SELECT, Common.MESSAGE_TITLE.CONFIRM, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == System.Windows.Forms.DialogResult.Yes)
                {
                    listChecked = clb_Mech.CheckedItems.Cast<Business.CodeDetail>().ToList();

                    parentForm.addCheckedMechanicism(listChecked);

                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Vui lòng lựa chọn ít nhất một Mechanicism!");
            }
        }
    }
}
